#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <string>
#include <strings.h>
#include <unistd.h>


int main()
{
    int fd = socket(AF_INET, SOCK_DGRAM, 0);

    struct sockaddr_in server_addr;
    bzero(&server_addr, sizeof server_addr);
    server_addr.sin_family = AF_INET;
    server_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
    server_addr.sin_port = htons(8080);

    // UDP 无连接（不可靠）
    // connect(fd, (struct sockaddr*)&server_addr, sizeof(server_addr));

    std::string buffer;
    std::getline(std::cin, buffer);

    sendto(fd, buffer.c_str(), buffer.size(), 0, (struct sockaddr*)&server_addr, sizeof server_addr);

    close(fd);
    return 0;
}